const mysql = require('mysql2/promise');

// 数据库配置
const dbConfig = {
  host: '43.143.253.188',
  user: 'nextjs',
  password: 'yEAiRE2jcxTyRBy5',
  database: 'nextjs',
  charset: 'utf8mb4'
};

// 根据表格数据创建的坐骑等级经验数据
const mountLevelExperienceData = [
  // 等级 1-10
  { level: 1, experience: 0, expToNext: 100, expPerTraining: 7500, trainingCount: 1, totalTraining: 0 },
  { level: 2, experience: 100, expToNext: 200, expPerTraining: 7500, trainingCount: 1, totalTraining: 1 },
  { level: 3, experience: 300, expToNext: 300, expPerTraining: 7500, trainingCount: 1, totalTraining: 2 },
  { level: 4, experience: 600, expToNext: 400, expPerTraining: 7500, trainingCount: 1, totalTraining: 3 },
  { level: 5, experience: 1000, expToNext: 500, expPerTraining: 7500, trainingCount: 1, totalTraining: 4 },
  { level: 6, experience: 1500, expToNext: 600, expPerTraining: 7500, trainingCount: 1, totalTraining: 5 },
  { level: 7, experience: 2100, expToNext: 700, expPerTraining: 7500, trainingCount: 1, totalTraining: 6 },
  { level: 8, experience: 2800, expToNext: 800, expPerTraining: 7500, trainingCount: 1, totalTraining: 7 },
  { level: 9, experience: 3600, expToNext: 900, expPerTraining: 7500, trainingCount: 1, totalTraining: 8 },
  { level: 10, experience: 4500, expToNext: 1450, expPerTraining: 7500, trainingCount: 1, totalTraining: 9 },
  
  // 等级 11-20
  { level: 11, experience: 5950, expToNext: 2145, expPerTraining: 7800, trainingCount: 1, totalTraining: 2 },
  { level: 12, experience: 8095, expToNext: 2345, expPerTraining: 7800, trainingCount: 1, totalTraining: 3 },
  { level: 13, experience: 10440, expToNext: 2545, expPerTraining: 7800, trainingCount: 1, totalTraining: 4 },
  { level: 14, experience: 12985, expToNext: 2745, expPerTraining: 7800, trainingCount: 1, totalTraining: 5 },
  { level: 15, experience: 15730, expToNext: 2945, expPerTraining: 7800, trainingCount: 1, totalTraining: 6 },
  { level: 16, experience: 18675, expToNext: 3145, expPerTraining: 7800, trainingCount: 1, totalTraining: 7 },
  { level: 17, experience: 21820, expToNext: 3345, expPerTraining: 7800, trainingCount: 1, totalTraining: 8 },
  { level: 18, experience: 25165, expToNext: 3545, expPerTraining: 7800, trainingCount: 1, totalTraining: 9 },
  { level: 19, experience: 28710, expToNext: 3745, expPerTraining: 7800, trainingCount: 1, totalTraining: 10 },
  { level: 20, experience: 32455, expToNext: 3945, expPerTraining: 7800, trainingCount: 1, totalTraining: 11 },
  
  // 等级 21-30
  { level: 21, experience: 36400, expToNext: 4145, expPerTraining: 7800, trainingCount: 1, totalTraining: 12 },
  { level: 22, experience: 40545, expToNext: 4345, expPerTraining: 7800, trainingCount: 1, totalTraining: 13 },
  { level: 23, experience: 44890, expToNext: 4545, expPerTraining: 7800, trainingCount: 1, totalTraining: 14 },
  { level: 24, experience: 49435, expToNext: 4745, expPerTraining: 7800, trainingCount: 1, totalTraining: 15 },
  { level: 25, experience: 54180, expToNext: 4945, expPerTraining: 7800, trainingCount: 1, totalTraining: 16 },
  { level: 26, experience: 59125, expToNext: 5145, expPerTraining: 7800, trainingCount: 1, totalTraining: 17 },
  { level: 27, experience: 64270, expToNext: 5345, expPerTraining: 7800, trainingCount: 1, totalTraining: 18 },
  { level: 28, experience: 69615, expToNext: 5545, expPerTraining: 7800, trainingCount: 1, totalTraining: 19 },
  { level: 29, experience: 75160, expToNext: 5745, expPerTraining: 7800, trainingCount: 1, totalTraining: 20 },
  { level: 30, experience: 80905, expToNext: 5945, expPerTraining: 7800, trainingCount: 1, totalTraining: 21 },
  
  // 等级 31-40
  { level: 31, experience: 86850, expToNext: 6145, expPerTraining: 7800, trainingCount: 1, totalTraining: 22 },
  { level: 32, experience: 92995, expToNext: 6345, expPerTraining: 7800, trainingCount: 1, totalTraining: 23 },
  { level: 33, experience: 99340, expToNext: 6545, expPerTraining: 7800, trainingCount: 1, totalTraining: 24 },
  { level: 34, experience: 105885, expToNext: 6745, expPerTraining: 7800, trainingCount: 1, totalTraining: 25 },
  { level: 35, experience: 112630, expToNext: 6945, expPerTraining: 7800, trainingCount: 1, totalTraining: 26 },
  { level: 36, experience: 119575, expToNext: 7145, expPerTraining: 7800, trainingCount: 1, totalTraining: 27 },
  { level: 37, experience: 126720, expToNext: 7345, expPerTraining: 7800, trainingCount: 1, totalTraining: 28 },
  { level: 38, experience: 134065, expToNext: 7545, expPerTraining: 7800, trainingCount: 1, totalTraining: 29 },
  { level: 39, experience: 141610, expToNext: 7745, expPerTraining: 7800, trainingCount: 1, totalTraining: 30 },
  { level: 40, experience: 149355, expToNext: 7945, expPerTraining: 7800, trainingCount: 1, totalTraining: 31 },
  
  // 等级 41-50
  { level: 41, experience: 157300, expToNext: 8145, expPerTraining: 7800, trainingCount: 1, totalTraining: 32 },
  { level: 42, experience: 165445, expToNext: 8345, expPerTraining: 7800, trainingCount: 1, totalTraining: 33 },
  { level: 43, experience: 173790, expToNext: 8545, expPerTraining: 7800, trainingCount: 1, totalTraining: 34 },
  { level: 44, experience: 182335, expToNext: 8745, expPerTraining: 7800, trainingCount: 1, totalTraining: 35 },
  { level: 45, experience: 191080, expToNext: 8945, expPerTraining: 7800, trainingCount: 1, totalTraining: 36 },
  { level: 46, experience: 200025, expToNext: 9145, expPerTraining: 7800, trainingCount: 1, totalTraining: 37 },
  { level: 47, experience: 209170, expToNext: 9345, expPerTraining: 7800, trainingCount: 1, totalTraining: 38 },
  { level: 48, experience: 218515, expToNext: 9545, expPerTraining: 7800, trainingCount: 1, totalTraining: 39 },
  { level: 49, experience: 228060, expToNext: 9745, expPerTraining: 7800, trainingCount: 1, totalTraining: 40 },
  { level: 50, experience: 237805, expToNext: 9945, expPerTraining: 7800, trainingCount: 1, totalTraining: 41 },
  
  // 等级 51-60
  { level: 51, experience: 247750, expToNext: 10145, expPerTraining: 7800, trainingCount: 1, totalTraining: 42 },
  { level: 52, experience: 257895, expToNext: 10345, expPerTraining: 7800, trainingCount: 1, totalTraining: 43 },
  { level: 53, experience: 268240, expToNext: 10545, expPerTraining: 7800, trainingCount: 1, totalTraining: 44 },
  { level: 54, experience: 278785, expToNext: 10745, expPerTraining: 7800, trainingCount: 1, totalTraining: 45 },
  { level: 55, experience: 289530, expToNext: 10945, expPerTraining: 7800, trainingCount: 1, totalTraining: 46 },
  { level: 56, experience: 300475, expToNext: 11145, expPerTraining: 7800, trainingCount: 1, totalTraining: 47 },
  { level: 57, experience: 311620, expToNext: 11345, expPerTraining: 7800, trainingCount: 1, totalTraining: 48 },
  { level: 58, experience: 322965, expToNext: 11545, expPerTraining: 7800, trainingCount: 1, totalTraining: 49 },
  { level: 59, experience: 334510, expToNext: 11745, expPerTraining: 7800, trainingCount: 1, totalTraining: 50 },
  { level: 60, experience: 346255, expToNext: 11945, expPerTraining: 7800, trainingCount: 1, totalTraining: 51 },
  
  // 等级 61-70
  { level: 61, experience: 358200, expToNext: 12145, expPerTraining: 7800, trainingCount: 1, totalTraining: 52 },
  { level: 62, experience: 370345, expToNext: 12345, expPerTraining: 7800, trainingCount: 1, totalTraining: 53 },
  { level: 63, experience: 382690, expToNext: 12545, expPerTraining: 7800, trainingCount: 1, totalTraining: 54 },
  { level: 64, experience: 395235, expToNext: 12745, expPerTraining: 7800, trainingCount: 1, totalTraining: 55 },
  { level: 65, experience: 407980, expToNext: 12945, expPerTraining: 7800, trainingCount: 1, totalTraining: 56 },
  { level: 66, experience: 420925, expToNext: 13145, expPerTraining: 7800, trainingCount: 1, totalTraining: 57 },
  { level: 67, experience: 434070, expToNext: 13345, expPerTraining: 7800, trainingCount: 1, totalTraining: 58 },
  { level: 68, experience: 447415, expToNext: 13545, expPerTraining: 7800, trainingCount: 1, totalTraining: 59 },
  { level: 69, experience: 460960, expToNext: 13745, expPerTraining: 7800, trainingCount: 1, totalTraining: 60 },
  { level: 70, experience: 474705, expToNext: 13945, expPerTraining: 7800, trainingCount: 1, totalTraining: 61 },
  
  // 等级 71-80
  { level: 71, experience: 488650, expToNext: 14145, expPerTraining: 7800, trainingCount: 1, totalTraining: 62 },
  { level: 72, experience: 502795, expToNext: 14345, expPerTraining: 7800, trainingCount: 1, totalTraining: 63 },
  { level: 73, experience: 517140, expToNext: 14545, expPerTraining: 7800, trainingCount: 1, totalTraining: 64 },
  { level: 74, experience: 531685, expToNext: 14745, expPerTraining: 7800, trainingCount: 1, totalTraining: 65 },
  { level: 75, experience: 546430, expToNext: 14945, expPerTraining: 7800, trainingCount: 1, totalTraining: 66 },
  { level: 76, experience: 561375, expToNext: 15145, expPerTraining: 7800, trainingCount: 1, totalTraining: 67 },
  { level: 77, experience: 576520, expToNext: 15345, expPerTraining: 7800, trainingCount: 1, totalTraining: 68 },
  { level: 78, experience: 591865, expToNext: 15545, expPerTraining: 7800, trainingCount: 1, totalTraining: 69 },
  { level: 79, experience: 607410, expToNext: 15745, expPerTraining: 7800, trainingCount: 1, totalTraining: 70 },
  { level: 80, experience: 623155, expToNext: 15945, expPerTraining: 7800, trainingCount: 1, totalTraining: 71 },
  
  // 等级 81-90
  { level: 81, experience: 639100, expToNext: 16145, expPerTraining: 7800, trainingCount: 1, totalTraining: 72 },
  { level: 82, experience: 655245, expToNext: 16345, expPerTraining: 7800, trainingCount: 1, totalTraining: 73 },
  { level: 83, experience: 671590, expToNext: 16545, expPerTraining: 7800, trainingCount: 1, totalTraining: 74 },
  { level: 84, experience: 688135, expToNext: 16745, expPerTraining: 7800, trainingCount: 1, totalTraining: 75 },
  { level: 85, experience: 704880, expToNext: 16945, expPerTraining: 7800, trainingCount: 1, totalTraining: 76 },
  { level: 86, experience: 721825, expToNext: 17145, expPerTraining: 7800, trainingCount: 1, totalTraining: 77 },
  { level: 87, experience: 738970, expToNext: 17345, expPerTraining: 7800, trainingCount: 1, totalTraining: 78 },
  { level: 88, experience: 756315, expToNext: 17545, expPerTraining: 7800, trainingCount: 1, totalTraining: 79 },
  { level: 89, experience: 773860, expToNext: 17745, expPerTraining: 7800, trainingCount: 1, totalTraining: 80 },
  { level: 90, experience: 791605, expToNext: 17945, expPerTraining: 7800, trainingCount: 1, totalTraining: 81 },
  
  // 等级 91-100
  { level: 91, experience: 809550, expToNext: 18145, expPerTraining: 7800, trainingCount: 1, totalTraining: 82 },
  { level: 92, experience: 827695, expToNext: 18345, expPerTraining: 7800, trainingCount: 1, totalTraining: 83 },
  { level: 93, experience: 846040, expToNext: 18545, expPerTraining: 7800, trainingCount: 1, totalTraining: 84 },
  { level: 94, experience: 864585, expToNext: 18745, expPerTraining: 7800, trainingCount: 1, totalTraining: 85 },
  { level: 95, experience: 883330, expToNext: 18945, expPerTraining: 7800, trainingCount: 1, totalTraining: 86 },
  { level: 96, experience: 902275, expToNext: 19145, expPerTraining: 7800, trainingCount: 1, totalTraining: 87 },
  { level: 97, experience: 921420, expToNext: 19345, expPerTraining: 7800, trainingCount: 1, totalTraining: 88 },
  { level: 98, experience: 940765, expToNext: 19545, expPerTraining: 7800, trainingCount: 1, totalTraining: 89 },
  { level: 99, experience: 960310, expToNext: 19745, expPerTraining: 7800, trainingCount: 1, totalTraining: 90 },
  { level: 100, experience: 980055, expToNext: 19945, expPerTraining: 7800, trainingCount: 1, totalTraining: 91 },
  
  // 等级 101-110
  { level: 101, experience: 1000000, expToNext: 20145, expPerTraining: 7800, trainingCount: 1, totalTraining: 92 },
  { level: 102, experience: 1020145, expToNext: 20345, expPerTraining: 7800, trainingCount: 1, totalTraining: 93 },
  { level: 103, experience: 1040490, expToNext: 20545, expPerTraining: 7800, trainingCount: 1, totalTraining: 94 },
  { level: 104, experience: 1061035, expToNext: 20745, expPerTraining: 7800, trainingCount: 1, totalTraining: 95 },
  { level: 105, experience: 1081780, expToNext: 20945, expPerTraining: 7800, trainingCount: 1, totalTraining: 96 },
  { level: 106, experience: 1102725, expToNext: 21145, expPerTraining: 7800, trainingCount: 1, totalTraining: 97 },
  { level: 107, experience: 1123870, expToNext: 21345, expPerTraining: 7800, trainingCount: 1, totalTraining: 98 },
  { level: 108, experience: 1145215, expToNext: 21545, expPerTraining: 7800, trainingCount: 1, totalTraining: 99 },
  { level: 109, experience: 1166760, expToNext: 21745, expPerTraining: 7800, trainingCount: 1, totalTraining: 100 },
  { level: 110, experience: 1188505, expToNext: 21945, expPerTraining: 7800, trainingCount: 1, totalTraining: 101 },
  
  // 等级 111-120
  { level: 111, experience: 1210450, expToNext: 22145, expPerTraining: 7800, trainingCount: 1, totalTraining: 102 },
  { level: 112, experience: 1232595, expToNext: 22345, expPerTraining: 7800, trainingCount: 1, totalTraining: 103 },
  { level: 113, experience: 1254940, expToNext: 22545, expPerTraining: 7800, trainingCount: 1, totalTraining: 104 },
  { level: 114, experience: 1277485, expToNext: 22745, expPerTraining: 7800, trainingCount: 1, totalTraining: 105 },
  { level: 115, experience: 1300230, expToNext: 22945, expPerTraining: 7800, trainingCount: 1, totalTraining: 106 },
  { level: 116, experience: 1323175, expToNext: 23145, expPerTraining: 7800, trainingCount: 1, totalTraining: 107 },
  { level: 117, experience: 1346320, expToNext: 23345, expPerTraining: 7800, trainingCount: 1, totalTraining: 108 },
  { level: 118, experience: 1369665, expToNext: 23545, expPerTraining: 7800, trainingCount: 1, totalTraining: 109 },
  { level: 119, experience: 1393210, expToNext: 23745, expPerTraining: 7800, trainingCount: 1, totalTraining: 110 },
  { level: 120, experience: 1416955, expToNext: 23945, expPerTraining: 7800, trainingCount: 1, totalTraining: 111 },
  
  // 等级 121-130
  { level: 121, experience: 1440900, expToNext: 24145, expPerTraining: 7800, trainingCount: 1, totalTraining: 112 },
  { level: 122, experience: 1465045, expToNext: 24345, expPerTraining: 7800, trainingCount: 1, totalTraining: 113 },
  { level: 123, experience: 1489390, expToNext: 24545, expPerTraining: 7800, trainingCount: 1, totalTraining: 114 },
  { level: 124, experience: 1513935, expToNext: 24745, expPerTraining: 7800, trainingCount: 1, totalTraining: 115 },
  { level: 125, experience: 1538680, expToNext: 24945, expPerTraining: 7800, trainingCount: 1, totalTraining: 116 },
  { level: 126, experience: 1563625, expToNext: 25145, expPerTraining: 7800, trainingCount: 1, totalTraining: 117 },
  { level: 127, experience: 1588770, expToNext: 25345, expPerTraining: 7800, trainingCount: 1, totalTraining: 118 },
  { level: 128, experience: 1614115, expToNext: 25545, expPerTraining: 7800, trainingCount: 1, totalTraining: 119 },
  { level: 129, experience: 1639660, expToNext: 25745, expPerTraining: 7800, trainingCount: 1, totalTraining: 120 },
  { level: 130, experience: 1665405, expToNext: 25945, expPerTraining: 7800, trainingCount: 1, totalTraining: 121 },
  
  // 等级 131-140
  { level: 131, experience: 1691350, expToNext: 26145, expPerTraining: 7800, trainingCount: 1, totalTraining: 122 },
  { level: 132, experience: 1717495, expToNext: 26345, expPerTraining: 7800, trainingCount: 1, totalTraining: 123 },
  { level: 133, experience: 1743840, expToNext: 26545, expPerTraining: 7800, trainingCount: 1, totalTraining: 124 },
  { level: 134, experience: 1770385, expToNext: 26745, expPerTraining: 7800, trainingCount: 1, totalTraining: 125 },
  { level: 135, experience: 1797130, expToNext: 26945, expPerTraining: 7800, trainingCount: 1, totalTraining: 126 },
  { level: 136, experience: 1824075, expToNext: 27145, expPerTraining: 7800, trainingCount: 1, totalTraining: 127 },
  { level: 137, experience: 1851220, expToNext: 27345, expPerTraining: 7800, trainingCount: 1, totalTraining: 128 },
  { level: 138, experience: 1878565, expToNext: 27545, expPerTraining: 7800, trainingCount: 1, totalTraining: 129 },
  { level: 139, experience: 1906110, expToNext: 27745, expPerTraining: 7800, trainingCount: 1, totalTraining: 130 },
  { level: 140, experience: 1933855, expToNext: 27945, expPerTraining: 7800, trainingCount: 1, totalTraining: 131 },
  
  // 等级 141-150
  { level: 141, experience: 1961800, expToNext: 28145, expPerTraining: 7800, trainingCount: 1, totalTraining: 132 },
  { level: 142, experience: 1989945, expToNext: 28345, expPerTraining: 7800, trainingCount: 1, totalTraining: 133 },
  { level: 143, experience: 2018290, expToNext: 28545, expPerTraining: 7800, trainingCount: 1, totalTraining: 134 },
  { level: 144, experience: 2046835, expToNext: 28745, expPerTraining: 7800, trainingCount: 1, totalTraining: 135 },
  { level: 145, experience: 2075580, expToNext: 28945, expPerTraining: 7800, trainingCount: 1, totalTraining: 136 },
  { level: 146, experience: 2104525, expToNext: 29145, expPerTraining: 7800, trainingCount: 1, totalTraining: 137 },
  { level: 147, experience: 2133670, expToNext: 29345, expPerTraining: 7800, trainingCount: 1, totalTraining: 138 },
  { level: 148, experience: 2163015, expToNext: 29545, expPerTraining: 7800, trainingCount: 1, totalTraining: 139 },
  { level: 149, experience: 2192560, expToNext: 29745, expPerTraining: 7800, trainingCount: 1, totalTraining: 140 },
  { level: 150, experience: 2222305, expToNext: 29945, expPerTraining: 7800, trainingCount: 1, totalTraining: 141 },
  
  // 等级 151-160
  { level: 151, experience: 2252250, expToNext: 30145, expPerTraining: 7800, trainingCount: 1, totalTraining: 142 },
  { level: 152, experience: 2282395, expToNext: 30345, expPerTraining: 7800, trainingCount: 1, totalTraining: 143 },
  { level: 153, experience: 2312740, expToNext: 30545, expPerTraining: 7800, trainingCount: 1, totalTraining: 144 },
  { level: 154, experience: 2343285, expToNext: 30745, expPerTraining: 7800, trainingCount: 1, totalTraining: 145 },
  { level: 155, experience: 2374030, expToNext: 30945, expPerTraining: 7800, trainingCount: 1, totalTraining: 146 },
  { level: 156, experience: 2404975, expToNext: 31145, expPerTraining: 7800, trainingCount: 1, totalTraining: 147 },
  { level: 157, experience: 2436120, expToNext: 31345, expPerTraining: 7800, trainingCount: 1, totalTraining: 148 },
  { level: 158, experience: 2467465, expToNext: 31545, expPerTraining: 7800, trainingCount: 1, totalTraining: 149 },
  { level: 159, experience: 2499010, expToNext: 31745, expPerTraining: 7800, trainingCount: 1, totalTraining: 150 },
  { level: 160, experience: 2530755, expToNext: 0, expPerTraining: 7800, trainingCount: 0, totalTraining: 151 }
];

class MountLevelExperienceCreator {
  constructor() {
    this.connection = null;
  }

  async connect() {
    try {
      this.connection = await mysql.createConnection(dbConfig);
      console.log('✅ 数据库连接成功');
    } catch (error) {
      console.error('❌ 数据库连接失败:', error.message);
      throw error;
    }
  }

  async createTable() {
    try {
      const createTableSQL = `
        CREATE TABLE IF NOT EXISTS mount_level_experience (
          level INT PRIMARY KEY COMMENT '等级',
          experience BIGINT NOT NULL COMMENT '该等级需要的总经验值',
          exp_to_next BIGINT NOT NULL COMMENT '升到下一级所需经验',
          exp_per_training INT NOT NULL COMMENT '训练一次所得经验',
          training_count INT NOT NULL COMMENT '升到下一级所需训练次数',
          total_training INT NOT NULL COMMENT '升到当前等级所需训练总次数',
          created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
          updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='坐骑等级经验表';
      `;

      await this.connection.execute(createTableSQL);
      console.log('✅ 坐骑等级经验表创建成功');
    } catch (error) {
      console.error('❌ 创建表失败:', error.message);
      throw error;
    }
  }

  async insertData() {
    try {
      // 清空现有数据
      await this.connection.execute('DELETE FROM mount_level_experience');
      console.log('✅ 清空现有数据');

      // 插入新数据
      const insertSQL = `
        INSERT INTO mount_level_experience 
        (level, experience, exp_to_next, exp_per_training, training_count, total_training)
        VALUES (?, ?, ?, ?, ?, ?)
      `;

      for (const data of mountLevelExperienceData) {
        await this.connection.execute(insertSQL, [
          data.level,
          data.experience,
          data.expToNext,
          data.expPerTraining,
          data.trainingCount,
          data.totalTraining
        ]);
      }

      console.log(`✅ 成功插入 ${mountLevelExperienceData.length} 条坐骑等级经验数据`);
    } catch (error) {
      console.error('❌ 插入数据失败:', error.message);
      throw error;
    }
  }

  async verifyData() {
    try {
      const [rows] = await this.connection.execute('SELECT COUNT(*) as count FROM mount_level_experience');
      console.log(`✅ 验证数据: 共 ${rows[0].count} 条记录`);

      // 显示前几条数据
      const [sampleRows] = await this.connection.execute(
        'SELECT * FROM mount_level_experience ORDER BY level LIMIT 10'
      );
      console.log('📊 前10条数据示例:');
      console.table(sampleRows);
    } catch (error) {
      console.error('❌ 验证数据失败:', error.message);
      throw error;
    }
  }

  async close() {
    if (this.connection) {
      await this.connection.end();
      console.log('✅ 数据库连接已关闭');
    }
  }

  async run() {
    try {
      await this.connect();
      await this.createTable();
      await this.insertData();
      await this.verifyData();
      console.log('🎉 坐骑等级经验数据创建完成！');
    } catch (error) {
      console.error('❌ 执行失败:', error.message);
    } finally {
      await this.close();
    }
  }
}

// 运行脚本
const creator = new MountLevelExperienceCreator();
creator.run();
